home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-06 | 5.2 KB | 199 lines | [TEXT/CWIE] |
- // ModelessCheckboxes.cp -- modeless dialog
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <TextEdit.h>
- #include <Appearance.h>
-
- #include "ResourceDefs.h"
- #include "Miscellany.h"
- #include "ControlUtils.h"
-
- #include "ModelessCheckboxes.h"
-
- #define kStandardCheck 1
- #define kXxCheck 2
- #define kCapTriangleLabel 3
- #define kGraphicBox 4
- #define kCapcicnLabel 5
- #define kLRCheck 6
- #define kCapicl8Label 7
- #define kLR2Check 8
- #define kCapICNLabel 9
- #define kLR3Check 10
- #define kCapPICTLabel 11
- #define kLR4Check 12
- #define kCapicl9Label 13
- #define kCheckboxCheck 14
- #define kBevelBox 15
- #define kCheckbox2Check 16
- #define kNextCheck 17
- #define kNext2Check 18
-
-
- //----------
- CModelessCheckboxes* CModelessCheckboxes::sDialog = nil;
-
- //----------
- // static
- CModelessCheckboxes* CModelessCheckboxes::Create ()
- {
- CModelessCheckboxes* dialog = new CModelessCheckboxes;
- DModelessCheckboxesData* data = new DModelessCheckboxesData;
-
- dialog->MakeDialog (DLOG_ModelessCheckboxes);
- dialog->ConnectToData (data);
-
- return dialog;
- }
-
- //----------
- // static
- CModelessCheckboxes* CModelessCheckboxes::Show ()
- {
- if (sDialog == nil) {
- sDialog = CModelessCheckboxes::Create ();
- }
- if (sDialog != nil) {
- ::SelectWindow (sDialog->mDialog);
- ::ShowWindow (sDialog->mDialog);
- }
- return sDialog;
- }
-
- //----------
- CModelessCheckboxes::CModelessCheckboxes ()
- {
- mData = nil;
- }
-
- //----------
- CModelessCheckboxes::~CModelessCheckboxes ()
- {
- sDialog = nil;
- }
-
- //----------
- void CModelessCheckboxes::FinishMake ()
- {
- mStandardHandle = GetControlItem (kStandardCheck);
- mXxHandle = GetControlItem (kXxCheck);
- mGraphicHandle = GetControlItem (kGraphicBox);
- mLRHandle = GetControlItem (kLRCheck);
- mLR2Handle = GetControlItem (kLR2Check);
- mLR3Handle = GetControlItem (kLR3Check);
- mLR4Handle = GetControlItem (kLR4Check);
- mCheckboxHandle = GetControlItem (kCheckboxCheck);
- mBevelHandle = GetControlItem (kBevelBox);
- mCheckbox2Handle = GetControlItem (kCheckbox2Check);
- SetBevelButtonGraphicAlignment (mCheckbox2Handle, kControlBevelButtonAlignCenter, 0, 0);
- mNextHandle = GetControlItem (kNextCheck);
- SetBevelButtonTextPlacement (mNextHandle, kControlBevelButtonPlaceToRightOfGraphic);
- SetBevelButtonTextAlignment (mNextHandle, kControlBevelButtonAlignTextFlushLeft, 0);
- SetBevelButtonGraphicAlignment (mNextHandle, kControlBevelButtonAlignLeft, 0, 0);
- mNext2Handle = GetControlItem (kNext2Check);
- SetBevelButtonTextPlacement (mNext2Handle, kControlBevelButtonPlaceBelowGraphic);
- SetBevelButtonTextAlignment (mNext2Handle, kControlBevelButtonAlignTextCenter, 0);
- SetBevelButtonGraphicAlignment (mNext2Handle, kControlBevelButtonAlignTop, 0, 0);
- }
-
- //----------
- void CModelessCheckboxes::ConnectToData (
- AMSignaler* inData)
- {
- AMDialog::ConnectToData (inData);
- mData = (DModelessCheckboxesData*) inData;
-
- SetControlValue (mStandardHandle, mData->GetStandard7 ());
- SetControlValue (mXxHandle, mData->GetXx3 ());
- SetControlValue (mLRHandle, mData->GetLR9 ());
- SetControlValue (mLR2Handle, mData->GetLR10 ());
- SetControlValue (mLR3Handle, mData->GetLR11 ());
- SetControlValue (mLR4Handle, mData->GetLR12 ());
- SetControlValue (mCheckboxHandle, mData->GetCheckbox5 ());
- SetControlValue (mCheckbox2Handle, mData->GetCheckbox6 ());
- SetControlValue (mNextHandle, mData->GetNext5 ());
- SetControlValue (mNext2Handle, mData->GetNext6 ());
- }
-
- //----------
- void CModelessCheckboxes::DataChanged (
- long inDataID)
- {
- if (inDataID == idStandard7) {
- SetControlValue (mStandardHandle, mData->GetStandard7 ());
- }
- if (inDataID == idXx3) {
- SetControlValue (mXxHandle, mData->GetXx3 ());
- }
- if (inDataID == idLR9) {
- SetControlValue (mLRHandle, mData->GetLR9 ());
- }
- if (inDataID == idLR10) {
- SetControlValue (mLR2Handle, mData->GetLR10 ());
- }
- if (inDataID == idLR11) {
- SetControlValue (mLR3Handle, mData->GetLR11 ());
- }
- if (inDataID == idLR12) {
- SetControlValue (mLR4Handle, mData->GetLR12 ());
- }
- if (inDataID == idCheckbox5) {
- SetControlValue (mCheckboxHandle, mData->GetCheckbox5 ());
- }
- if (inDataID == idCheckbox6) {
- SetControlValue (mCheckbox2Handle, mData->GetCheckbox6 ());
- }
- if (inDataID == idNext5) {
- SetControlValue (mNextHandle, mData->GetNext5 ());
- }
- if (inDataID == idNext6) {
- SetControlValue (mNext2Handle, mData->GetNext6 ());
- }
- }
-
-
- //----------
- void CModelessCheckboxes::DoItem (
- SInt16 inItemHit)
- {
- switch (inItemHit) {
- case kStandardCheck:
- mData->SetStandard7 (ToggleCheckbox (mStandardHandle));
- break;
- case kXxCheck:
- mData->SetXx3 (ToggleCheckbox (mXxHandle));
- break;
- case kLRCheck:
- mData->SetLR9 (ToggleCheckbox (mLRHandle));
- break;
- case kLR2Check:
- mData->SetLR10 (ToggleCheckbox (mLR2Handle));
- break;
- case kLR3Check:
- mData->SetLR11 (ToggleCheckbox (mLR3Handle));
- break;
- case kLR4Check:
- mData->SetLR12 (ToggleCheckbox (mLR4Handle));
- break;
- case kCheckboxCheck:
- mData->SetCheckbox5 (ToggleCheckbox (mCheckboxHandle));
- break;
- case kCheckbox2Check:
- mData->SetCheckbox6 (GetControlValue (mCheckbox2Handle));
- break;
- case kNextCheck:
- mData->SetNext5 (GetControlValue (mNextHandle));
- break;
- case kNext2Check:
- mData->SetNext6 (GetControlValue (mNext2Handle));
- break;
-
- } // switch
- }
-